package com.lvshou.medicalkit.module.main;


import com.common.libhttp.result.HttpResponseException;
import com.common.libhttp.rxjava.observable.ResultTransformer;
import com.common.libhttp.rxjava.observer.BaseObserver;
import com.lvshou.medicalkit.base.BasePresenter;
import com.lvshou.medicalkit.model.Holiday;
import com.lvshou.medicalkit.utils.HttpClient;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 *
 */
public class MainPresenter extends BasePresenter<MainContract.View> implements MainContract.Presenter {

    @Override
    public void checkAppVersion() {
        HttpClient
                .getApiService()
                .checkAppVersion()
                .compose(getView().bindLifecycle())
                .compose(ResultTransformer.transformer())
                .subscribe(new BaseObserver<Holiday>() {

                    @Override
                    protected void onSuccess(Holiday info) {
                        getView().onSuccess("", info);
                    }

                    @Override
                    protected void onFailed(HttpResponseException responseException) {
                        super.onFailed(responseException);
                        getView().onError(responseException);
                    }


                });

    }


}
